package org.neuedu.chapter09_0701.demo02;

import java.util.Calendar;
import java.util.Date;

public class CalendarDemo01 {
    public static void main(String[] args) {
        // 通过静态方法 getInstance 获取 Calendar 子类对象
        Calendar calendar = Calendar.getInstance();
        System.out.println(calendar);

        // Date getTime()
        Date date = calendar.getTime();
        System.out.println(date);
        System.out.println(date.getTime());
        System.out.println(calendar.getTime().getTime());

        // get 方法
        int year = calendar.get(Calendar.YEAR);
        System.out.println(year);
        int month = calendar.get(Calendar.MONTH) + 1;
        System.out.println(month);
        int date1 = calendar.get(Calendar.DATE);
        System.out.println(date1);
        int hoursOf24 = calendar.get(Calendar.HOUR_OF_DAY);
        System.out.println(hoursOf24);
        int hourOf12 = calendar.get(Calendar.HOUR);
        System.out.println(hourOf12);
        int min = calendar.get(Calendar.MINUTE);
        System.out.println(min);
        int sec = calendar.get(Calendar.SECOND);
        System.out.println(sec);
        int week = calendar.get(Calendar.DAY_OF_WEEK);
        System.out.println(week);
    }
}
